package com.baidu.health.service;

import com.baidu.health.util.resFaqVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baidu.health.pojo.TbTask;
import com.baidu.health.service.TbTaskService;
import com.baidu.health.mapper.TbTaskMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 */
@Service
public class TbTaskServiceImpl extends ServiceImpl<TbTaskMapper, TbTask>
    implements TbTaskService{

    @Autowired
    TbTaskMapper tbTaskMapper;

    @Override
    public List<TbTask> list1() {
        List<TbTask> tasklist=tbTaskMapper.selectList(null);
        return tasklist;
    }

    @Override
    public resFaqVo taskAdd(TbTask tbTaskadd) {
        tbTaskMapper.insert(tbTaskadd);
        return new resFaqVo(200, "成功", null);
    }

//    @Override
//    public void taskDeleteByTid(Integer tid) {
//        tbTaskMapper.deleteById(tid);
//    }

    @Override
    public resFaqVo selectPage(TbTask tbTaskPage) {
        Page<TbTask> page=new Page<>(tbTaskPage.getCurrent(),tbTaskPage.getPagesize());
        QueryWrapper<TbTask> query=new QueryWrapper<>();
        query.orderByDesc("task_Starttime");

        Page<TbTask> page1=tbTaskMapper.selectPage(page, query);
        return new resFaqVo(200, "成功", page1);
    }

    @Override
    public resFaqVo taskDeleteByTaskid(TbTask tbTaskd) {
        System.out.println("-----"+tbTaskd.getTaskId());
        tbTaskMapper.deleteById(tbTaskd.getTaskId());
        return new resFaqVo(200, "删除成功", null);
    }

}




